﻿/*
 * NetSystem.h
 */
#ifndef __GDK_NETSYSTEM_H__
#define __GDK_NETSYSTEM_H__

#include <gdk/core/System.h>
#include <gdk/core/MessagePipe.h>
#include <gdk/net/Socket.h>
#include <gdk/net/NetAddress.h>
#include <gdk/net/NetConnection.h>
#include <queue>


namespace gdk
{



	///////////////////////////////////////////////
	class GDK_NET_EXPORT NetSystem : public System
	{
		DECLARE_CLASS_HANDLE(NetSystem)

	private:
		MessagePipe			_messagePipe;
		NetConnectionMap	_mapNetConnection;

	protected:
		NetSystem(void);

	public:
		virtual void onTick(uint32_t timeSinceLastTick);

	public:
		bool addNetConnection(NetConnection* conn);
		void removeNetConnection(const Uuid &clientId);
		NetConnection* getNetConnection(const Uuid &clientId) const;
		void closeAllNetConnection(void);

		__INLINE__ MessagePipe& getMessagePipe(void) { return _messagePipe; }
	};
	typedef NetSystem::Handle NetSystemPtr;


} //namespace gdk


#endif //__GDK_NETSYSTEM_H__
